package com.javafactroy.kunlong.bip.icp.netty.server.handler;

import com.javafactroy.kunlong.bip.icp.common.consts.IMsgType;
import io.netty.channel.ChannelHandler;
import com.javafactroy.kunlong.bip.icp.factory.AppMessageFactory;
import com.javafactroy.kunlong.bip.icp.factory.iface.IMessageHandler;
import com.javafactroy.kunlong.bip.icp.message.base.iface.IMessage;
import com.javafactroy.kunlong.bip.icp.message.dxp.base.DxpMsgResp;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

@Component
@Slf4j
@ChannelHandler.Sharable
public class DxpMsgHandler implements IMessageHandler {

    @Override
    public DxpMsgResp execute(IMessage message) {
        log.info("server execute DxpMsgHandler default...");
        DxpMsgResp resp= DxpMsgResp.buildMessage();
        //resp.getHeader().setMsgId(message.getHeader());
        return resp;
    }

    public static void register() {
        System.out.println(" server register DxpMsgHandler...");
        AppMessageFactory.getInst().registerHandler(""+ IMsgType.MsgType_Dxp_Stub_Default, new DxpMsgHandler());

    }

    static {
        register();
    }
}